package com.hrc.springboot.controller;

import com.hrc.springboot.exception.UserNotExistException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Arrays;
import java.util.Map;

@Controller
public class HelloController {

    @ResponseBody
    @RequestMapping("/hello")
    public String hello(@RequestParam("user") String user) {
        if (user.equals("aaa"))
            throw new UserNotExistException();
        return "Hello World!!!";
    }

    @RequestMapping("/test")
    public String input(Map<String, Object> map) {
        map.put("key", "value");
        map.put("k1", "v1");
        map.put("k2", "v2");
        map.put("k3", Arrays.asList("java ", "python ", "golang ", "c#"));
        map.put("k4", "<h1>Hello World!!!</h1>");
        return "success";
    }
}
